/**     
 * @Title: MonitorServlet.java   
 * @Package me.xxy.mq.demo.servlet   
 * @Description: TODO
 * @author weiwei 
 * @date 2018年5月30日 下午5:51:36   
 * @version V1.0     
 */
package me.xxy.mq.demo.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import me.xxy.mq.core.MessageListener;
import me.xxy.mq.demo.MessageType;
import me.xxy.mq.demo.SpringBeanAware;

/**
 * @ClassName: MonitorServlet
 * @Description: TODO
 * @author weiwei
 * @date 2018年5月30日 下午5:51:36
 * 
 */
public class MonitorServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public MonitorServlet() {

	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取mt实例
		MessageListener messageMonitor = (MessageListener) SpringBeanAware.getBean("messageListener");
		ConsoleWebSocket.socket.sendMessage("待处理消息个数：" + messageMonitor.getMessageCount(MessageType.DEMO_MESSAGE));
		// response.getOutputStream().print("message gas been saved to MessageTrunk, cost "+(System.currentTimeMillis()-startTime)+"ms. See result in console.");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
